package com.terrynoya.fight.evaluation
{
	import com.terrynoya.fight.evaluation.token.NumberData;

	public class Node
	{
		private var _token:Token;
		
		private var _chilren:Array;

		private var _arguments:Array;
		
		private var _precedenceOverride:Boolean;
		
		public static var zeroNode:Node = new Node(new Token("0",new NumberData())); 
		
		public function Node(token:Token)
		{
			this._token = token;
			this._chilren = new Array();
			this._arguments = new Array();
		}
		
		public function getChildAt(index:int):Node
		{
			return this._chilren[index];
		}
		
		public function get childLength():int 
		{
			return this._chilren.length;
		}

		public function get precedenceOverride():Boolean
		{
			return _precedenceOverride;
		}

		public function set precedenceOverride(value:Boolean):void
		{
			_precedenceOverride = value;
		}

		public function get token():Token
		{
			return _token;
		}

		public function set token(value:Token):void
		{
			_token = value;
		}
		
		public function addChild(value:Node):void
		{
			this._chilren.push(value);
		}

		public function get chilren():Array
		{
			return _chilren;
		}

		public function set chilren(value:Array):void
		{
			_chilren = value;
		}

		public function get arguments():Array
		{
			return _arguments;
		}

		public function set arguments(value:Array):void
		{
			_arguments = value;
		}
		
		public function get value():String 
		{
			return this._token.text;
		}
		
		public function excute(data:Object):*
		{
			var inter:ExpressionInterpretor = new ExpressionInterpretor();
			return inter.excute(this,data);
		}

	}
}